package com.schezhi.link.model.datasource.info;

import lombok.Data;
import java.io.Serializable;

/**
 * @author JiaLing.Fan
 * @version 1.0
 * @date 2023/12/7 14:40
 * @description DataSourceMetaDataEntity
 */

@Data
public class DBMetaDataInfo implements Serializable {
    /**
     * JDBC driver class name
     * Example: "com.mysql.jdbc.Driver"
     * JDBC驱动类名
     * 示例："com.mysql.jdbc.Driver"
     */
    private String driverClassName;
    /**
     * Database connection URL
     * Example: "jdbc:mysql://localhost:3306/mydb"
     * 数据库连接URL
     * 示例："jdbc:mysql://localhost:3306/mydb"
     */
    private String url;
    /**
     * Database username
     * 数据库用户名
     */
    private String username;
    /**
     * Database password
     * 数据库密码
     */
    private String password;
    /**
     * Initial number of connections when pool starts
     * Default: 2 (recommended value between 1-10)
     * 连接池启动时初始建立的连接数
     * 默认值：2（建议值在1-10之间）
     */
    private int initialSize = 2;
    /**
     * Maximum number of active connections
     * Default: 10 (typical value between 20-50 for production)
     * 最大活跃连接数
     * 默认值：10（生产环境典型值20-50）
     */
    private int maxActive = 10;
    /**
     * Minimum number of idle connections
     * -1 means same as initialSize
     * 最小空闲连接数
     * -1表示与initialSize相同
     */
    private int minIdle = -1;
    /**
     * Maximum wait time (milliseconds) to get a connection
     * Default: 60000ms (1 minute)
     * 获取连接时的最大等待时间（毫秒）
     * 默认值：60000毫秒（1分钟）
     */
    private long maxWait = 60 * 1000L;
    /**
     * Interval (milliseconds) to check idle connections
     * Default: 60000ms (1 minute)
     * 检查空闲连接的间隔时间（毫秒）
     * 默认值：60000毫秒（1分钟）
     */
    private long timeBetweenEvictionRunsMillis = 60 * 1000L;
    /**
     * Minimum time (milliseconds) a connection can remain idle before being evicted
     * Default: 1800000ms (30 minutes)
     * 连接保持空闲而不被驱逐的最小时间（毫秒）
     * 默认值：1800000毫秒（30分钟）
     */
    private long minEvictableIdleTimeMillis = 1000L * 60L * 30L;
    /**
     * Maximum time (milliseconds) a connection can remain idle before being evicted
     * Default: 25200000ms (7 hours)
     * 连接保持空闲而不被驱逐的最大时间（毫秒）
     * 默认值：25200000毫秒（7小时）
     */
    private long maxEvictableIdleTimeMillis = 1000L * 60L * 60L * 7;
    /**
     * SQL query to validate connection health
     * Default: "select 1" (simple ping query)
     * 验证连接健康的SQL查询
     * 默认值："select 1"（简单ping查询）
     */
    private String validationQuery = "select 1";
    /**
     * Timeout (seconds) for validation query
     * -1 means no timeout
     * 验证查询的超时时间（秒）
     * -1表示无超时
     */
    private int validationQueryTimeout = -1;
    /**
     * Test connection when borrowing from pool
     * Not recommended for performance reasons
     * 从池中借用连接时测试连接
     * 出于性能原因不推荐
     */
    private boolean testOnBorrow = false;
    /**
     * Test connection when returning to pool
     * Not recommended for performance reasons
     * 连接返回池时测试连接
     * 出于性能原因不推荐
     */
    private boolean testOnReturn = false;
    /**
     * Test connections while idle
     * Recommended for detecting broken connections
     * 在空闲时测试连接
     * 推荐用于检测破损连接
     */
    private boolean testWhileIdle = true;
    /**
     * Enable pooling of PreparedStatements
     * Improves performance for frequently used statements
     * 启用预编译语句池
     * 提高频繁使用语句的性能
     */
    private boolean poolPreparedStatements = false;
    /**
     * Maximum number of open PreparedStatements
     * -1 means no limit
     * 打开的预编译语句的最大数量
     * -1表示无限制
     */
    private int maxOpenPreparedStatements = -1;
    /**
     * Share PreparedStatements between connections
     * Only works when poolPreparedStatements=true
     * 在连接之间共享预编译语句
     * 仅在poolPreparedStatements=true时有效
     */
    private boolean sharePreparedStatements = false;
    /**
     * Filters for monitoring and protection
     * Default: "stat,wall" (statistics + SQL firewall)
     * 用于监控和保护的过滤器
     * 默认值："stat,wall"（统计+SQL防火墙）
     */
    private String filters = "stat,wall";

}
